<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form-model ref="formRef">
        <div class="search-title">查询条件</div>
        <a-row>
          <a-col :span="4">
            <div style="margin-right: 12px">
              <a-form-model-item prop="id"
                ><a-input v-model="queryParam.id" placeholder="请输入RFID标签流水号" allowClear />
              </a-form-model-item>
            </div>
          </a-col>
          <a-col :span="4">
            <div style="margin-right: 12px">
              <a-form-model-item prop="rfidBar"
                ><a-input v-model="queryParam.rfidBar" placeholder="请输入RFID码" allowClear />
              </a-form-model-item>
            </div>
          </a-col>
          <a-col :span="4">
            <div style="margin-right: 12px">
              <a-form-model-item prop="productName"
                ><a-input v-model="queryParam.productName" placeholder="请输入产品名称" allowClear />
              </a-form-model-item>
            </div>
          </a-col>

          <a-col :span="4">
            <div style="margin-right: 12px">
              <a-form-model-item prop="productSpec"
                ><a-input v-model="queryParam.productSpec" placeholder="请输入规格型号" allowClear />
              </a-form-model-item>
            </div>
          </a-col>

          <a-col :span="4">
            <div style="margin-right: 12px">
              <a-form-model-item prop="batch"
                ><a-input v-model="queryParam.batch" placeholder="请输入产品批号" allowClear />
              </a-form-model-item>
            </div>
          </a-col>

          <a-col :span="4">
            <div style="margin-top: 4px">
              <a-button icon="search" style="margin-right: 20px" @click="searchQuery()" type="primary"> 查询 </a-button>
              <a-button icon="reload" style="margin-right: 20px" @click="searchReset()"> 重置 </a-button>
            </div>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8">
            <div style="margin-top: 4px">
              <a-button icon="plus" style="margin-right: 20px" @click="handleAdd" type="primary">
                新增RFID标签
              </a-button>
              <a-button type="primary" icon="download" @click="handleExportXls('rfid')">导出</a-button>
            </div>
          </a-col>
        </a-row>
      </a-form-model>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- 高级查询区域 -->
      <!-- <j-super-query
          :fieldList="superFieldList"
          ref="superQueryModal"
          @handleSuperQuery="handleSuperQuery"
        ></j-super-query> -->
      
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
       

        <span slot="action" slot-scope="text, record">
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>

    <rfidModal ref="modalForm" @ok="modalFormOk"></rfidModal>
  </a-card>
</template>

<script>
import { mapState, mapGetters } from 'vuex'
import { stateObjToArray } from '@/utils/common.js'

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import rfidModal from './modules/rfidModal'

export default {
  name: 'SaleOrderList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
      rfidModal,
  },
  data() {
    return {
      description: 'RFID管理页面',
      // 表头
      columns: [
        {
          title: 'RFID标签流水号',
          align: 'center',
          dataIndex: 'id',
        },
        {
          title: 'RFID码',
          align: 'center',
          dataIndex: 'rfidBar',
        },
        {
          title: '产品名称',
          align: 'center',
          dataIndex: 'productName',
        },
        {
          title: '规格型号',
          align: 'center',
          dataIndex: 'productSpec',
        },
        {
          title: '批号',
          align: 'center',
          dataIndex: 'batch',
        },

        {
          title: '失效日期',
          align: 'center',
          dataIndex: 'validity',
        },
        {
          title: '公司名称',
          align: 'center',
          dataIndex: 'productYlqxzcrbarmc',
        },
        {
          title: '绑定产品时间',
          align: 'center',
          dataIndex: 'createTime',
        },
        {
          title: '操作人',
          dataIndex: 'createBy',
          align: 'center',
        },

        // {
        //   title: '操作',
        //   dataIndex: 'action',
        //   align: 'center',
        //   fixed: 'right',
        //   width: 147,
        //   scopedSlots: { customRender: 'action' },
        // },
      ],

      url: {
        list: '/wms/wmsZdyUdiMainTaskDetail/list',
        delete: '/wms/wmsSaleOrder/delete',
        deleteBatch: '/wms/wmsSaleOrder/deleteBatch',
        exportXlsUrl: 'wms/wmsZdyUdiMainTaskDetail/exportXls',
        importExcelUrl: 'wms/wmsSaleOrder/importExcel',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    ...mapGetters(['userInfo']),
    ...mapState({
      saleOrderTypes: (s) => {
        return stateObjToArray(s.order.saleOrderTypes)
      },
      inOrderStates: (s) => s.order.inOrderStates,
      saleOrderStates: (s) => {
        return stateObjToArray(s.order.saleOrderStates)
      },
      warehouseOptions: (s) => {
        return stateObjToArray(s.dictionary.enableWarehouse)
      },
      enableWarehouse: (s) => s.dictionary.enableWarehouse,
    }),
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}${this.url.importExcelUrl}`
    },
  },
  methods: {
    // dateChange(e) {
    //   console.log(e);
    //   this.queryParam.createTime = moment(e._d).format('YYYY-MM-DD')
    // },
   

    

    handleExport(e) {
      // console.log('handleExport', e)
      this.handleExportXls('一品一码绑定_' + e.orderNo, { id: e.id, field: '' })
    },
    handleExport1(e) {
      this.handleExportXls('一品一码绑定')
    },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'orderNo', text: '订单号' })
      fieldList.push({ type: 'string', value: 'orderType', text: '订单类型' })
      fieldList.push({ type: 'string', value: 'state', text: '状态' })
      fieldList.push({ type: 'int', value: 'sums', text: '数量' })
      fieldList.push({ type: 'int', value: 'createBy', text: '创建人' })
      fieldList.push({ type: 'string', value: 'createTime', text: '公司' })
      fieldList.push({ type: 'string', value: 'warehourse', text: '所属仓库' })
      this.superFieldList = fieldList
    },
    
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.search-title {
  font-size: 16px;
  font-weight: 650;
  margin-bottom: 10px;
}
.ant-form-item {
  margin-bottom: 8px;
}
</style>
